import React, { PureComponent } from 'react';
import { connect } from 'dva';
import {
  Form,
} from 'antd';
import styles from './style.less';
import ResponsiveEmbed from 'react-responsive-embed';
const FormItem = Form.Item;
import docCookies from "../../common/DocCookies";
@connect(state => ({
  contentManager: state.contentManager,
}))
@Form.create()
export default class ContentAdd extends PureComponent {
  state = {
    id:"",
    rsId:docCookies.getItem("rsId"),
    isEdit:false,
  };

  ////初始化渲染后触发 整个过程只调用一次
  componentDidMount() {
    const { form , dispatch} = this.props;
    if(this.props.location.query) {
      var isEdit = true;
      var id = this.props.location.query.id;
      this.setState({
        id:id,
        isEdit:isEdit,
      });
    }
  }
  render() {
    const { id,rsId,isEdit} = this.state;
    var fileSrc = "";
    if(isEdit){
        fileSrc = "http://fm.umakr.cn/ueditor/index.html?isEdit=true&id="+id;
    }else {
      fileSrc = "http://fm.umakr.cn/ueditor/index.html?isEdit=false&rsId="+rsId;
    }
    return (
      <div>
        {<ResponsiveEmbed src={fileSrc} allowFullScreen />}
      </div>
    );
  }
}
